/*
  学习目标：useEffect监听多个状态的变化

*/
import React from "react";
import { useState, useEffect } from "react";

export default function App() {
  const [count, setCount] = useState(0);
  const [msg, setMsg] = useState("hello");

  // 合起来写
  // useEffect(() => {
  //   document.title = count + msg;
  // }, [count, msg]);

  useEffect(() => {
    document.title = count + msg;
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [count]);

  useEffect(() => {
    document.title = count + msg;
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [msg]);
  return (
    <div>
      <h1>{count}</h1>
      <button onClick={() => setCount(count + 1)}>+1</button>

      <h2>{msg}</h2>
      <button onClick={() => setMsg(msg + "~")}>+~</button>
    </div>
  );
}
